<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context.xsd">

	<!-- Define the controllers using annotations -->
	<bean
		class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
	<bean
		class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
	<context:component-scan base-package="de.dvdverleih.controller" />

	<!-- ******************* -->
	<!-- DB and Hibernate -->
	<!-- ******************* -->

	<bean class="de.dvdverleih.Startup" init-method="initDB">
		<property name="driverClass" value="com.mysql.jdbc.Driver" />
		<property name="user" value="root" />
		<property name="password" value="" />
		<property name="defaultDBurl" value="jdbc:mysql://localhost:3306/mysql" />
		<property name="newDB" value="dvdverleihservice" />
	</bean>

	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
		destroy-method="close">
		<property name="driverClass" value="com.mysql.jdbc.Driver" />
		<property name="jdbcUrl"
			value="jdbc:mysql://localhost:3306/dvdverleihservice" />
		<property name="user" value="root" />
		<property name="password" value="" />
		<property name="minPoolSize" value="2" />
		<property name="maxPoolSize" value="4" />
	</bean>

	<bean id="hibernateSessionFactory"
		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="annotatedClasses">
			<list>
				<value>de.dvdverleih.model.Kunden</value>
				<value>de.dvdverleih.model.Dvd</value>
				<value>de.dvdverleih.model.Verleih</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
				<prop key="hibernate.hbm2ddl.auto">update</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
			</props>
		</property>
	</bean>

	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
	</bean>

	<!-- ******************* -->
	<!-- Data Access Objects -->
	<!-- ******************* -->

	<bean id="verleihDao" class="de.dvdverleih.dao.VerleihDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
	</bean>

	<bean id="kundenDao" class="de.dvdverleih.dao.KundenDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
		<!-- <property name="verleihDao" ref="verleihDao"></property> -->
	</bean>

	<bean id="dvdDao" class="de.dvdverleih.dao.DvdDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
		<!-- <property name="verleihDao" ref="verleihDao"></property> -->
	</bean>


	<!-- ******************* -->
	<!-- Controllers -->
	<!-- ******************* -->

	<bean id="kundenController" class="de.dvdverleih.controller.KundenController">
		<property name="kundenDao" ref="kundenDao" />
	</bean>

	<bean id="dvdController" class="de.dvdverleih.controller.DvdController">
		<property name="dvdDao" ref="dvdDao" />
	</bean>

	<bean id="verleihController" class="de.dvdverleih.controller.VerleihController">
		<property name="verleihDao" ref="verleihDao" />
		<property name="dvdDao" ref="dvdDao" />
		<property name="kundenDao" ref="kundenDao" />
	</bean>

	<!-- ******************* -->
	<!-- Views -->
	<!-- ******************* -->

	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/view/" />
		<property name="suffix" value=".jsp" />
	</bean>

</beans>